package com.xx.pmis.web.util;

import com.xx.pmis.model.LuckyData;
import com.xx.pmis.model.util.LuckyBlue;


public class LuckyBlueUtil {

	// 01
	public static LuckyBlue GetLuckyBlueOfB01(LuckyData ld)
			throws NumberFormatException {
		LuckyBlue luckyBlue = GetLuckyBlue(ld);
		luckyBlue.setB01("01");
		return luckyBlue;
	}

	// 02
	public static LuckyBlue GetLuckyBlueOfB02(LuckyData ld)
			throws NumberFormatException {
		LuckyBlue luckyBlue = GetLuckyBlue(ld);
		luckyBlue.setB02("02");
		return luckyBlue;
	}

	// 03
	public static LuckyBlue GetLuckyBlueOfB03(LuckyData ld)
			throws NumberFormatException {
		LuckyBlue luckyBlue = GetLuckyBlue(ld);
		luckyBlue.setB03("03");
		return luckyBlue;
	}

	// 04
	public static LuckyBlue GetLuckyBlueOfB04(LuckyData ld)
			throws NumberFormatException {
		LuckyBlue luckyBlue = GetLuckyBlue(ld);
		luckyBlue.setB04("04");
		return luckyBlue;
	}

	// 05
	public static LuckyBlue GetLuckyBlueOfB05(LuckyData ld)
			throws NumberFormatException {
		LuckyBlue luckyBlue = GetLuckyBlue(ld);
		luckyBlue.setB05("05");
		return luckyBlue;
	}

	// 06
	public static LuckyBlue GetLuckyBlueOfB06(LuckyData ld)
			throws NumberFormatException {
		LuckyBlue luckyBlue = GetLuckyBlue(ld);
		luckyBlue.setB06("06");
		return luckyBlue;
	}

	// 07
	public static LuckyBlue GetLuckyBlueOfB07(LuckyData ld)
			throws NumberFormatException {
		LuckyBlue luckyBlue = GetLuckyBlue(ld);
		luckyBlue.setB07("07");
		return luckyBlue;
	}

	// 08
	public static LuckyBlue GetLuckyBlueOfB08(LuckyData ld)
			throws NumberFormatException {
		LuckyBlue luckyBlue = GetLuckyBlue(ld);
		luckyBlue.setB08("08");
		return luckyBlue;
	}

	// 09
	public static LuckyBlue GetLuckyBlueOfB09(LuckyData ld)
			throws NumberFormatException {
		LuckyBlue luckyBlue = GetLuckyBlue(ld);
		luckyBlue.setB09("09");
		return luckyBlue;
	}

	// 10
	public static LuckyBlue GetLuckyBlueOfB10(LuckyData ld)
			throws NumberFormatException {
		LuckyBlue luckyBlue = GetLuckyBlue(ld);
		luckyBlue.setB10("10");
		return luckyBlue;
	}

	// 11
	public static LuckyBlue GetLuckyBlueOfB11(LuckyData ld)
			throws NumberFormatException {
		LuckyBlue luckyBlue = GetLuckyBlue(ld);
		luckyBlue.setB11("11");
		return luckyBlue;
	}

	// 12
	public static LuckyBlue GetLuckyBlueOfB12(LuckyData ld)
			throws NumberFormatException {
		LuckyBlue luckyBlue = GetLuckyBlue(ld);
		luckyBlue.setB12("12");
		return luckyBlue;
	}

	// 13
	public static LuckyBlue GetLuckyBlueOfB13(LuckyData ld)
			throws NumberFormatException {
		LuckyBlue luckyBlue = GetLuckyBlue(ld);
		luckyBlue.setB13("13");
		return luckyBlue;
	}

	// 14
	public static LuckyBlue GetLuckyBlueOfB14(LuckyData ld)
			throws NumberFormatException {
		LuckyBlue luckyBlue = GetLuckyBlue(ld);
		luckyBlue.setB14("14");
		return luckyBlue;
	}

	// 15
	public static LuckyBlue GetLuckyBlueOfB15(LuckyData ld)
			throws NumberFormatException {
		LuckyBlue luckyBlue = GetLuckyBlue(ld);
		luckyBlue.setB15("15");
		return luckyBlue;
	}

	// 16
	public static LuckyBlue GetLuckyBlueOfB16(LuckyData ld)
			throws NumberFormatException {
		LuckyBlue luckyBlue = GetLuckyBlue(ld);
		luckyBlue.setB16("16");
		return luckyBlue;
	}

	// // 奇数还是偶数
	// public static String jiOrOu(String arg) {
	// int n = Integer.parseInt(arg);
	// if (n % 2 == 0) {
	// return ("偶");
	// } else {
	// return ("奇");
	// }
	// }
	//

	// 奇数还是偶数
	public static void jiOrOu(LuckyBlue lb, String arg) {
		int n = Integer.parseInt(arg);
		if (n % 2 == 0) {
			lb.setJi("");
			lb.setOu("偶");
		} else {
			lb.setJi("奇");
			lb.setOu("");
		}
	}

	// 质数还是合数
	public static String zhiOrHe(String arg) {
		int n = Integer.parseInt(arg);
		if (n == 2)
			return ("质");

		for (int i = 2; i < n; i++) {
			if (n % i == 0)
				return ("合");
		}

		return ("质");

	}

	// 五行属性
	public static void wuXingShuXing(LuckyBlue lb, String arg) {
		int n = Integer.parseInt(arg);
		if (n == 9 || n == 10) {
			lb.setJin("金");
			lb.setMu("");
			lb.setShui("");
			lb.setHuo("");
			lb.setTu("");
		} else if (n == 3 || n == 4 || n == 15 || n == 16) {
			lb.setJin("");
			lb.setMu("木");
			lb.setShui("");
			lb.setHuo("");
			lb.setTu("");
		} else if (n == 1 || n == 12 || n == 13) {
			lb.setJin("");
			lb.setMu("");
			lb.setShui("水");
			lb.setHuo("");
			lb.setTu("");
		} else if (n == 6 || n == 7) {
			lb.setJin("");
			lb.setMu("");
			lb.setShui("");
			lb.setHuo("火");
			lb.setTu("");
		} else if (n == 2 || n == 5 || n == 8 || n == 11 || n == 14) {
			lb.setJin("");
			lb.setMu("");
			lb.setShui("");
			lb.setHuo("");
			lb.setTu("土");
		} else {
			lb.setJin("");
			lb.setMu("");
			lb.setShui("");
			lb.setHuo("");
			lb.setTu("");
		}

	}

	// 蓝球
	public static LuckyBlue GetLuckyBlue(LuckyData ld)
			throws NumberFormatException {
		LuckyBlue luckyBlue = new LuckyBlue();
		luckyBlue.setIssueNumber(ld.getIssueNumber());
		luckyBlue.setLuckyRedCode(ld.getR1() + " " + ld.getR2() + " "
				+ ld.getR3() + " " + ld.getR4() + " " + ld.getR5() + " "
				+ ld.getR6());
		luckyBlue.setLuckyBlueCode(ld.getB1());
		luckyBlue.setB01("");
		luckyBlue.setB02("");
		luckyBlue.setB03("");
		luckyBlue.setB04("");
		luckyBlue.setB05("");
		luckyBlue.setB06("");
		luckyBlue.setB07("");
		luckyBlue.setB08("");
		luckyBlue.setB09("");
		luckyBlue.setB10("");
		luckyBlue.setB11("");
		luckyBlue.setB12("");
		luckyBlue.setB13("");
		luckyBlue.setB14("");
		luckyBlue.setB15("");
		luckyBlue.setB16("");
		jiOrOu(luckyBlue, ld.getB1());
		if (zhiOrHe(ld.getB1()).equals("质")) {
			luckyBlue.setZhi("质");
			luckyBlue.setHe("");
		} else {
			luckyBlue.setZhi("");
			luckyBlue.setHe("合");
		}
		wuXingShuXing(luckyBlue, ld.getB1());

		return luckyBlue;
	}

}
